#ifndef VTKCONSTANTS_HPP
#define VTKCONSTANTS_HPP

#include "meshTypes.hpp"
#include "magic_enum.hpp"
#include "tinyxml2.h"

namespace hms::vtk {

namespace xml = tinyxml2;

using magic_enum::enum_name;
using magic_enum::enum_cast;

/* for unstructured mesh representation, either "PolyData" or "UnstructuredGrid"
 * can be used. "PolyData" requires fewer arrays and is therefore preferred.*/
constexpr bool usePolyData {true};
constexpr auto rootName {"VTKFile"};
constexpr auto uniType    {"ImageData"};
constexpr auto rectType   {"RectilinearGrid"};
constexpr auto structType {"StructuredGrid"};
constexpr auto unstrType  { usePolyData ? "PolyData" : "UnstructuredGrid" };
constexpr auto uniExt    {"vti"};
constexpr auto rectExt   {"vtr"};
constexpr auto structExt {"vts"};
constexpr auto unstrExt  { usePolyData ? "vtp" : "vtu" };
constexpr auto bindingExt { "pvd" };
constexpr auto dataNode  {"CellData"};
constexpr auto decl { "xml version=\"1.0\" standalone=\"yes\"" };
constexpr auto nComponentsName { "NumberOfComponents" };
constexpr auto boundaryNode {"Boundary"};
constexpr auto boundaryChild {"Patch"};
constexpr auto constNode {"ConstantFields"};
constexpr auto constChild {"ConstantField"};
constexpr auto sourceNode {"SourceFields"};
constexpr auto sourceChild {"SourceField"};

template<typename MeshType>
constexpr decltype(auto) getVtkFormat(){
	if constexpr ( std::is_same_v<MeshType, Mesh> )
		return unstrType;
	if constexpr ( std::is_same_v<MeshType, UniMesh> )
		return uniType;
	if constexpr ( std::is_same_v<MeshType, RectMesh> )
		return rectType;
	if constexpr ( std::is_same_v<MeshType, StructMesh> )
		return structType;
}

template<typename MeshType>
constexpr decltype(auto) getVtkExtension(){
	if constexpr ( std::is_same_v<MeshType, Mesh> )
		return unstrExt;
	if constexpr ( std::is_same_v<MeshType, UniMesh> )
		return uniExt;
	if constexpr ( std::is_same_v<MeshType, RectMesh> )
		return rectExt;
	if constexpr ( std::is_same_v<MeshType, StructMesh> )
		return structExt;
}

} // end namespace hms::vtk

#endif